/**
 * Copyright 2012 Balaji Thennarangam
 */
package com.kathez.ops.business;

import java.util.List;

import com.kathez.business.AbstractKathezBusiness;
import com.kathez.ops.entity.User;
import com.kathez.ops.repository.UserRegistrarRepository;
import com.kathez.util.commonutils.RepositoryLocator;

/**
 * @author Balaji.T
 * @version 1.0
 * @since 1.0
 */
public class OpsUserRegistrar extends AbstractKathezBusiness implements
		UserRegistrar {
	
	private UserRegistrarRepository repository;

	/* (non-Javadoc)
	 * @see com.kathez.ops.business.UserRegistrar#addUser(com.kathez.ops.entity.User)
	 */
	@Override
	public User addUser(User user) {
		return getRepository().addUser(user);
	}

	/* (non-Javadoc)
	 * @see com.kathez.ops.business.UserRegistrar#modifyUser(com.kathez.ops.entity.User)
	 */
	@Override
	public User modifyUser(User user) {
		return getRepository().modifyUser(user);
	}

	/* (non-Javadoc)
	 * @see com.kathez.ops.business.UserRegistrar#deleteUser(com.kathez.ops.entity.User)
	 */
	@Override
	public User deleteUser(User user) {
		return getRepository().deleteUser(user);
	}

	/* (non-Javadoc)
	 * @see com.kathez.ops.business.UserRegistrar#searchUser(com.kathez.ops.entity.User)
	 */
	@Override
	public List<User> searchUser(User user) {
		return getRepository().searchUser(user);
	}

	/**
	 * @return the repository
	 */
	public UserRegistrarRepository getRepository() {
		if(this.repository == null){
			this.repository = (UserRegistrarRepository)RepositoryLocator.locateRepository(repository.getClass().getName());
		}
		return this.repository;
	}

	/**
	 * @param repository the repository to set
	 */
	public void setRepository(UserRegistrarRepository repository) {
		this.repository = repository;
	}

}
